package com.aiyige.page.selectinterest.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.aiyige.page.selectinterest.InterestPage;
import com.aiyige.page.selectinterest.StatePage;
import com.aiyige.page.selectinterest.model.IndustryItem;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by zhuyakun on 2017/10/25.
 */

public class SelectInterestPagerAdapter extends FragmentPagerAdapter {
    List<IndustryItem> data;
    List<Fragment> fragmentList = new LinkedList<>();

    public SelectInterestPagerAdapter(FragmentManager fm, List<IndustryItem> industryItemList) {
        super(fm);
        data = industryItemList;
        for (IndustryItem i : data) {
            if (i.isStats()) {
                fragmentList.add(StatePage.newInstance(data));
            } else {
                fragmentList.add(InterestPage.newInstance(i,data));
            }
        }
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }
}
